package com.ufcg.lvc.client.my;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.types.DragAppearance;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.DragStartEvent;
import com.smartgwt.client.widgets.events.DragStartHandler;

/**
 * Esta classe representa uma imagem que pode ser movida
 *  
 * @author Larissa Nepomuceno Costa
 * @version 1
 * @since 08/10/2012
 */
public class MyDragPhoto extends Img {

	public MyDragPhoto(String caminho) {
		
		setSrc(GWT.getHostPageBaseURL() + "Thumb"+caminho.split("Fotos")[1]);
		setCursor(Cursor.MOVE);
		setCanDrag(true);
		setCanDrop(true);
		setDragAppearance(DragAppearance.TARGET);
		setDragStartDistance(1);
		setLayoutAlign(Alignment.CENTER);
		setCanDragReposition(true);
		setOverflow(Overflow.VISIBLE);
		addDragStartHandler(new DragStartHandler() {
			
			@Override
			public void onDragStart(DragStartEvent event) {
				boolean start = event.isLeftButtonDown();
				start  = !start;
			}
		});

	}
	
}